﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    x:Class="XamlCast.Player.MainPage"
    d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}" DataContext="{StaticResource MainPageVM}">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="RunningHostStates">
    			<VisualState x:Name="InsideBrowser"/>
    			<VisualState x:Name="OutOfBrowser">
    				<Storyboard>
    					<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnGoBack" Storyboard.TargetProperty="(UIElement.Visibility)">
    						<DiscreteObjectKeyFrame KeyTime="00:00:00">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Visible</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    					<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnGoForward" Storyboard.TargetProperty="(UIElement.Visibility)">
    						<DiscreteObjectKeyFrame KeyTime="00:00:00">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Visible</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    					<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="PageTitle" Storyboard.TargetProperty="(UIElement.Visibility)">
    						<DiscreteObjectKeyFrame KeyTime="00:00:00">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Visible</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    		</VisualStateGroup>
    		<VisualStateGroup x:Name="UpdateStates">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="00:00:00.5000000"/>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="VersionUpToDate"/>
    			<VisualState x:Name="NewVersionAvailable">
    				<Storyboard>
    					<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="VersionMessages" Storyboard.TargetProperty="(UIElement.Opacity)">
    						<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
    					</DoubleAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>

    	<Grid.ColumnDefinitions>
    		<ColumnDefinition MinWidth="200"/>
    		<ColumnDefinition Width="2*"/>
    		<ColumnDefinition MinWidth="200"/>
    	</Grid.ColumnDefinitions>
    	<Grid.RowDefinitions>
    		<RowDefinition Height="42"/>
    		<RowDefinition/>
    		<RowDefinition Height="100"/>
    	</Grid.RowDefinitions>

        <Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}" Margin="0" VerticalAlignment="Stretch" Grid.ColumnSpan="3">
        	<Grid.ColumnDefinitions>
        		<ColumnDefinition/>
        		<ColumnDefinition Width="Auto"/>
        	</Grid.ColumnDefinitions>
            <StackPanel x:Name="Header" Orientation="Horizontal" Margin="10,0,5,0">
        		<StackPanel x:Name="NavigationButtons" Margin="0" Orientation="Horizontal" VerticalAlignment="Center">
        			<Button x:Name="btnGoBack" IsEnabled="{Binding CanGoBack, ElementName=ContentFrame}" Width="30" Content="&lt;" VerticalAlignment="Center" Visibility="Collapsed" Click="btnGoBack_Click" Margin="0,0,5,0"/>
        			<Button x:Name="btnGoForward" IsEnabled="{Binding CanGoForward, ElementName=ContentFrame}" Width="30" Content="&gt;" VerticalAlignment="Center" Visibility="Collapsed" Click="bntGoForward_Click" Margin="0,0,5,0"/>

        		</StackPanel>
        		<TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" 
        			Text="{Binding SiteTitle}" Margin="0"/>
        		<TextBlock x:Name="PageTitle" Text="{Binding SelectedPodcast.Title}" Style="{StaticResource ApplicationNameStyle}" Margin="4,0,0,0" Visibility="Collapsed"/>
                
        	</StackPanel>
            <TextBlock x:Name="VersionMessages" Margin="5,0,10,0" IsHitTestVisible="False" Opacity="0" Foreground="#FFFD4626" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="1" FontWeight="Bold"><Run Text="Nova versão disponível."/><LineBreak/><Run Text="Reinicie para atualizar."/></TextBlock>

        </Grid>
        
        <ListBox x:Name="FeedList" Margin="10,25,0,10" SelectedItem="{Binding SelectedPodcast, Mode=TwoWay}" SelectionChanged="FeedList_SelectionChanged" Grid.Row="1" ItemsSource="{Binding FeedItems}" ItemTemplate="{StaticResource FeedItemTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.RowSpan="2"/>

    	<navigation:Frame x:Name="ContentFrame" Source="/Podcasts/" Style="{StaticResource ContentFrameStyle}" NavigationFailed="ContentFrame_NavigationFailed" Margin="10,10,10,0" Grid.Column="1" Grid.Row="1">
    		<navigation:Frame.UriMapper>
    			<uriMapper:UriMapper>
    				<uriMapper:UriMapping Uri="/Podcasts/{slug}" MappedUri="/Views/PodcastEpisode.xaml?slug={slug}"/>
    				<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
    			</uriMapper:UriMapper>
    		</navigation:Frame.UriMapper>
    	</navigation:Frame>
        
    	<ListBox x:Name="TweetsFeed" Margin="0,25,10,10" Grid.Row="1" Grid.Column="3" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.RowSpan="2"/>
        
    	<layoutToolkit:Accordion x:Name="AuthorsBio" HorizontalAlignment="Stretch" Grid.Row="2" Grid.Column="1" VerticalAlignment="Stretch" ExpandDirection="Right" Margin="10" Cursor="Hand">
    		<layoutToolkit:AccordionItem Content="Content">
    			<layoutToolkit:AccordionItem.Header>
    				<Image Width="50" Height="50" Source="Icons/kelps.jpg" Stretch="Fill" ToolTipService.ToolTip="Kelps Leite de Sousa"/>
    			</layoutToolkit:AccordionItem.Header>
    		</layoutToolkit:AccordionItem>
    		<layoutToolkit:AccordionItem Content="Content">
    			<layoutToolkit:AccordionItem.Header>
    				<Image Width="50" Height="50" Source="Icons/sonnino.jpg" Stretch="Fill" ToolTipService.ToolTip="Roberto Sonnino"/>
    			</layoutToolkit:AccordionItem.Header>
    		</layoutToolkit:AccordionItem>
    		<layoutToolkit:AccordionItem Content="Content">
    			<layoutToolkit:AccordionItem.Header>
    				<Image Width="50" Height="50" Source="Icons/kono.jpg" Stretch="Fill" ToolTipService.ToolTip="Rodrigo Kono"/>
    			</layoutToolkit:AccordionItem.Header>
    		</layoutToolkit:AccordionItem>
    	</layoutToolkit:Accordion>

    </Grid>

</UserControl>